﻿
@{
    ViewBag.Title = "WorkEfficiency";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="@SiteUrl.GetStaticResourceScriptUrl("~/js/highcharts/highcharts.js")"></script>
<script src="@SiteUrl.GetStaticResourceScriptUrl("~/js/highcharts/modules/exporting.js")"></script>
<script>
    var captionCon = "<span id='headInfo'></span>";
    var time;
    var type;
    $(function () {
        loadChart();
        gridList();
    });

    function loadChart() {
        var OutpatientList = [];
        var InpatientList = [];
        $.ajax({
            url: "/TherapeutistManage/TherapeutistCompleteList/GetVisitSC?r=" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                if (data.data) {
                    OutpatientList = data.data.OutpatientList;
                    InpatientList = data.data.InpatientList
                } else {
                    for (var i = 0; i < 12; i++) {
                        OutpatientList.push([0]);
                        InpatientList.push([0]);
                    }
                }
            }
        })
        $('#bar').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: '治疗师工作效率分析'
            },
            xAxis: {
                categories: [
                    '一月',
                    '二月',
                    '三月',
                    '四月',
                    '五月',
                    '六月',
                    '七月',
                    '八月',
                    '九月',
                    '十月',
                    '十一月',
                    '十二月'
                ]
            },
            yAxis: {
                min: 0,
                title: {
                    text: '单位 (小时)'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} 小时</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                },
                series: {
                    cursor: 'pointer',
                    point: {
                        events: {
                            click: function () {
                                time = this.x;
                                type = this.series.name;
                                $("#headInfo").text(type + "治疗师" + this.category + "明细");
                                $("#btn_search").trigger('click');
                            }
                        }
                    },
                    marker: {
                        lineWidth: 1
                    }
                }
            },
            series: [{
                name: "门诊",
                data: [
                        OutpatientList[0].num, OutpatientList[1].num, OutpatientList[2].num, OutpatientList[3].num, OutpatientList[4].num, OutpatientList[5].num, OutpatientList[6].num, OutpatientList[7].num, OutpatientList[8].num, OutpatientList[9].num, OutpatientList[10].num, OutpatientList[11].num
                ]
            }, {
                name: "住院",
                data: [
                           InpatientList[0].num, InpatientList[1].num, InpatientList[2].num, InpatientList[3].num, InpatientList[4].num, InpatientList[5].num, InpatientList[6].num, InpatientList[7].num, InpatientList[8].num, InpatientList[9].num, InpatientList[10].num, InpatientList[11].num
                ]
            }]
        });
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/TherapeutistManage/TherapeutistCompleteList/GetVisitDetailSC?r=" + Math.random(),
            caption: captionCon,
            postData: {},
            height: $(window).height() - 320,
            colModel: [
                { label: "主键", name: "Id", hidden: true, key: true },
                { label: "治疗师", name: "NAME", width: 80 },
                { label: '治疗时间', name: "jzsj", width: 80, align: 'left' },
                { label: '时长(分)', name: 'sc', width: 100, align: 'left' }
            ],
            pager: "#gridPager",
            sortname: 'jzsj desc',
            rowNum: '1000',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam',
                {
                    postData: { time: time, type: type },
                    url: "/TherapeutistManage/TherapeutistCompleteList/GetVisitDetailSC?r=" + Math.random(),
                }).trigger('reloadGrid');
        });
    }


</script>
<div class="bar-chart">
    <div class="panel panel-default">
        <div id="bar" style="height: 200px; width: 100%;"></div>
    </div>
</div>
<div class="gridPanel">
    <input type="hidden" id="btn_search" />
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
